/**
 * 
 */
package client;

import java.util.concurrent.ConcurrentSkipListMap;

import protocol.GameStateTypes;
import structures.Maze;
import structures.Player;

/**
 * Describes client game state, update ID, 
 * player ID, and team. All methods are static.
 * Initialized in ConnectBody constructor.
 * @author lilywong
 *
 */
public class CtfState {
	
	private static int gameState;	// to be set by game update body
	private static int updateState;	// which update are we on
	private static Player myPlayer;
	private static ConcurrentSkipListMap<Integer,Player> playerList 
		= new ConcurrentSkipListMap<Integer,Player>(); 
		
	
	/* Accessors */
	public static int getGameState() { return gameState; }
	public static int getUpdateState() { return updateState; }
	public static Player getMyPlayer() { return myPlayer; }
	public static ConcurrentSkipListMap getPlayerList() { return playerList; }
	
	/* Constructor: called in ConnectBody constructor */
	public CtfState( int playerId, int team ) {
		myPlayer = new Player( playerId, team );
		// dummy put it in first home cell
		myPlayer.setPos( Maze.getHome1Positions().get(0) );
		// place my player into list
		playerList.put( myPlayer.getId(), myPlayer);
		
		// default values
		gameState = GameStateTypes.NOT_YET_STARTED;
		updateState = GameStateTypes.NOT_YET_UPDATED;
	}
	
	/* Mutators */
	public static void setGameState( int gs ) {
		if ( gs == GameStateTypes.TERMINATED )
			System.err.println("Server terminated!");
		//TODO
		gameState = gs;
	}
	
	public static void setUpdateState( int us ) {
		updateState = us;
	}
}
